package br.uvv.Service;

import java.io.Serializable;
import java.util.List;

import org.primefaces.model.SortOrder;

import br.uvv.Dao.CenarioBaseDAO;
import br.uvv.Model.CenarioBase;
import br.uvv.Util.DAOException;
import br.uvv.Util.RNException;

public class CenarioBaseService implements Serializable {

	private static final long serialVersionUID = -5595644097598874483L;
	
	private CenarioBaseDAO dao = new CenarioBaseDAO();

	public void salvarCenario(CenarioBase cenarioBaseInstance) throws RNException {
		try {
			dao.salvar(cenarioBaseInstance);
		} catch (DAOException e) {
			e.printStackTrace();
		}
	}

	public void atualizarCenario(CenarioBase cenarioBaseInstance) throws RNException {
		try {
			dao.salvar(cenarioBaseInstance);
		} catch (DAOException e) {
			e.printStackTrace();
		}
	}

	public void excluirCenario(CenarioBase cenarioBaseInstance) throws RNException {
		try {
			dao.remover(cenarioBaseInstance);
		} catch (DAOException e) {
			e.printStackTrace();
		}
		
	}

	public List<CenarioBase> listarCenarioBase(int first, int pageSize,
			String sortField, SortOrder sortOrder, String varNome,
			String varFluxo) throws RNException {
		try {
			return dao.listar(first, pageSize, sortField, sortOrder, varNome, varFluxo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RNException(e);
		}
	}

	public int countCenarioBase(String varNome, String varFluxo) throws RNException {
		try {
			return dao.count(varNome, varFluxo);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RNException(e);
		}
	}

	public CenarioBase selecionarCenarioBase(Long id) throws RNException {
		try {
			return dao.selecionar(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RNException(e);
		}
	}

}
